<html>
<head>
<meta charset="UTF-8">
<title>Entity - KBEngine base</title>
<link href="../../style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td align=left style="background:#708090"> <font size=15 color=#ffffff> KBEngine </font></td></tr>
</table> <hr>
<h1>Entity class</h1>

<p style="text-align: center;"><span class="module_h1">[<a href="../Modules/KBEngine.html" class="module_h1">KBEngine module</a>]</span></p>
<p>Entity is part of the <a href="../Modules/KBEngine.html">KBEngine</a> module. <a href="#detailed_description">More...</a></p><p></p><pre>import KBEngine</pre>

<h2><a href="#" onClick="obj=document.getElementById( 'functions' );vis = (obj.style.display == 'none') ? 'block' : 'none'; obj.style.display = vis; return false;" class="h2">Member functions</a></h2>
<table id="functions" cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr><td>
<span class="function_list">def <a href="#addTimer" class="function_list" >addTimer</a>( self, initialOffset, repeatOffset=0, userArg=0 ):</span>
</td></tr>

<tr><td>
<span class="function_list">def <a href="#createCellEntity" class="function_list" >createCellEntity</a>( self, cellEntityCall ):</span>
</td></tr>

<tr><td>
<span class="function_list">def <a href="#createCellEntityInNewSpace" class="function_list" >createCellEntityInNewSpace</a>( self, cellappIndex ):</span>
</td></tr>

<tr><td>
<span class="function_list">def <a href="#delTimer" class="function_list" >delTimer</a>( self, id ):</span>
</td></tr>

<tr><td>
<span class="function_list">def <a href="#destroy" class="function_list" >destroy</a>( self, deleteFromDB, writeToDB ):</span>
</td></tr>

<tr><td>
<span class="function_list">def <a href="#destroyCellEntity" class="function_list" >destroyCellEntity</a>( self ):</span>
</td></tr>

<tr><td>
<span class="function_list">def <a href="#writeToDB" class="function_list" >writeToDB</a>( self, callback, shouldAutoLoad, dbInterfaceName ):</span>
</td></tr>

<tr><td>
    <span class="function_list">def <a href="#getComponent" class="function_list" >getComponent</a>( self, componentName, all ):</span>
</td></tr>

<tr><td>
    <span class="function_list">def <a href="#fireEvent" class="function_list" >fireEvent</a>( self, eventName, *args ):</span>
</td></tr>

<tr><td>
    <span class="function_list">def <a href="#registerEvent" class="function_list" >registerEvent</a>( self, eventName, callback ):</span>
</td></tr>

<tr><td>
    <span class="function_list">def <a href="#deregisterEvent" class="function_list" >deregisterEvent</a>( self, eventName, callback ):</span>
</td></tr>

</table>

<h2><a href="#" onClick="obj=document.getElementById( 'callbacks' );vis = (obj.style.display == 'none') ? 'block' : 'none'; obj.style.display = vis; return false;" class="h2">Callback functions</a></h2>
<table id="callbacks" cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr><td>
<span class="function_list">def <a href="#onCreateCellFailure" class="function_list" >onCreateCellFailure</a>( self ):</span>
</td></tr>

<tr><td>
<span class="function_list">def <a href="#onDestroy" class="function_list" >onDestroy</a>( self ):</span>
</td></tr>

<tr><td>
<span class="function_list">def <a href="#onGetCell" class="function_list" >onGetCell</a>( self ):</span>
</td></tr>

<tr><td>
<span class="function_list">def <a href="#onLoseCell" class="function_list" >onLoseCell</a>( self ):</span>
</td></tr>

<tr><td>
<span class="function_list">def <a href="#onPreArchive" class="function_list" >onPreArchive</a>( self ):</span>
</td></tr>

<tr><td>
<span class="function_list">def <a href="#onRestore" class="function_list" >onRestore</a>( self ):</span>
</td></tr>

<tr><td>
<span class="function_list">def <a href="#onTimer" class="function_list" >onTimer</a>( self, timerHandle, userData ):</span>
</td></tr>

<tr><td>
<span class="function_list">def <a href="#onWriteToDB" class="function_list" >onWriteToDB</a>( self, cellData ):</span>
</td></tr>

</table>

<h2><a href="#" onClick="obj=document.getElementById( 'attributes' );vis = (obj.style.display == 'none') ? 'block' : 'none'; obj.style.display = vis; return false;" class="h2">Attributes</a></h2>
<table id="attributes" cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr valign=top><td><a href="#cell" class="attribute_list" >cell</a></td><td>&nbsp; Read-only <a href=../../keywords.html#EntityCall>CellEntityCall</a>
</td></tr>

<tr valign=top><td><a href="#cellData" class="attribute_list" >cellData</a></td><td>&nbsp; <a href="CELLDATADICT.html">CELLDATADICT</a>
</td></tr>

<tr valign=top><td><a href="#className" class="attribute_list" >className</a></td><td>&nbsp; Read-only <a href="STRING.html">string</a>
</td></tr>

<tr valign=top><td><a href="#client" class="attribute_list" >client</a></td><td>&nbsp; Read-only <a href=../../keywords.html#EntityCall>ClientEntityCall</a>
</td></tr>

<tr valign=top><td><a href="#databaseID" class="attribute_list" >databaseID</a></td><td>&nbsp; Read-only <a href="int64.html">int64</a>
</td></tr>

<tr valign=top><td><a href="#databaseInterfaceName" class="attribute_list" >databaseInterfaceName</a></td><td>&nbsp; Read-only <a href="STRING.html">string</a>
</td></tr>

<tr valign=top><td><a href="#id" class="attribute_list" >id</a></td><td>&nbsp; Read-only <a href="int32.html">int32</a>
</td></tr>

<tr valign=top><td><a href="#isDestroyed" class="attribute_list" >isDestroyed</a></td><td>&nbsp; <a href="bool.html">bool</a>
</td></tr>

<tr valign=top><td><a href="#shouldAutoArchive" class="attribute_list" >shouldAutoArchive</a></td><td>&nbsp; True, False or <a href="../Modules/KBEngine.html">KBEngine</a>.<a href=KBEngine.html#NEXT_ONLY>NEXT_ONLY</a>
</td></tr>

<tr valign=top><td><a href="#shouldAutoBackup" class="attribute_list" >shouldAutoBackup</a></td><td>&nbsp; True, False or <a href="../Modules/KBEngine.html">KBEngine</a>.<a href=KBEngine.html#NEXT_ONLY>NEXT_ONLY</a>
</td></tr>

</table>

<hr>
<a name="detailed_description"></a><h2>A detailed description</h2>
This <a href="Entity.html">Entity</a> class represents an <a href="Entity.html">Entity</a> 
that resides on the <a href="../index.html">Baseapp</a>.
<a href="Entity.html">Entities</a> can be created using the <a href="../Modules/KBEngine.html">KBEngine</a>.<a href=../Modules/KBEngine.html#createEntity>createEntity</a> 
function (as well as functions prefixed by createEntity). 
An <a href="Entity.html">Entity</a> can also be remotely created using the <a href="../../cellapp/index.html">Cellapp</a> 
function <a href="../Modules/KBEngine.html">KBEngine</a>.<a href=../../cellapp/Modules/KBEngine.html#createEntityOnBaseApp>createEntityOnBaseApp</a>.
<br><br>
A base <a href="Entity.html">Entity</a> can be linked to an active <a href=../../keywords.html#cell>cell</a> 
entity and can be used to create an associated <a href=../../keywords.html#cell>cell</a> entity. 
This class allows you to create and destroy <a href=../../keywords.html#cell>cell</a> 
entities, register a timer on the base entity, or access the contact 
information for this object.<br>
You can also access a <a href="../../keywords.html#EntityCall">CellEntityCall</a> 
through which this base entity can communicate with its <a href=../../keywords.html#cell>cell</a> 
entity (the associated <a href=../../keywords.html#cell>cell</a> entity 
can be moved to a different <a href=../../keywords.html#cell>cell</a> 
when KBEngine performs load balancing as a result of the movement of the <a href=../../keywords.html#cell>cell</a> 
entity).

<hr>
<h2>Member function documentation</h2>

<a name="addTimer"></a><p class="function_definition">
<span class="function_definition">def addTimer( <i>self, initialOffset, repeatOffset=0, userArg=0</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
Register a timer. The timer is triggered by the callback function 
<i><a href="#onTimer">onTimer</a></i>, which will be executed the first 
time after "initialOffset" seconds, and then executed once every "repeatOffset" 
seconds. A "userArg" parameter can be set (integer only).
<br><br>
The <i><a href="#onTimer">onTimer</a></i> function must be defined in the 
base part of the entity with two parameters. The first is an integer, 
the timer id (which can be used to remove the timer's "<a href="#delTimer">delTimer</a>" 
function), and the second is the user parameter "userArg".
<br><br>
Example:

<pre><pre># Here is an example of using addTimer
import <a href="../Modules/KBEngine.html">KBEngine</a>
&nbsp;
class MyBaseEntity( <a href="../Modules/KBEngine.html">KBEngine</a>.<a href="Entity.html">Entity</a> ):
&nbsp;
    def __init__( self ):
        <a href="../Modules/KBEngine.html">KBEngine</a>.<a href="Entity.html">Entity</a>.__init__( self )
&nbsp;
        # Add a timer, trigger for the first time after 5 seconds, and execute once per second afterwards. The user parameter is 9.
        self.addTimer( 5, 1, 9 )
&nbsp;
        # Add a timer and execute it once after 1 second. The default user parameter is 0.
        self.addTimer( 1 )
&nbsp;
    # <a href="Entity.html">Entity</a> timer callback "onTimer" is called
    def onTimer( self, id, userArg ):
        print "MyBaseEntity.onTimer called: id %i, userArg: %i" % ( id, userArg )
        # If this is a repeated timer, when the timer is no longer needed, call the following function to remove it:
        #     self.delTimer( id )</pre>
</pre>
</div>

<p>
<span class="function_parameter">parameters:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr valign=top><td><span class="function_parameter_name"><i>initialOffset</i></span></td><td><span class="function_parameter_description">
float, specifies the time interval in seconds for the timer to trigger 
the first callback.
</span></td></tr>

<tr valign=top><td><span class="function_parameter_name"><i>repeatOffset</i></span></td><td><span class="function_parameter_description">
float, specifies the time interval (in seconds) after each execution of 
the first callback execution. You must remove the timer with the function <a href="#delTimer">delTimer</a>, 
otherwise it will continue to repeat. Values less than or equal to 0 will 
be ignored.
</span></td></tr>

<tr valign=top><td><span class="function_parameter_name"><i>userArg</i></span></td><td><span class="function_parameter_description">
integer, specifies the value of the userArg parameter when invoking the "<a href="#onTimer">onTimer</a>" callback.
</span></td></tr>

</table>
</p>

<p>
<span class="function_return">returns:Z</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">
<tr><td>integer, the internal id of the timer. This id can be used to 
remove the timer using <a href="#delTimer">delTimer</a>.
</td></tr>
</table>
</p>

<a name="createCellEntity"></a><p class="function_definition">
<span class="function_definition">def createCellEntity( <i>self, cellEntityCall</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
Requests to create an associated entity in a <a href=../../keywords.html#cell>cell</a>. 
<br><br>
The information used to create the <a href=../../keywords.html#cell>cell</a> 
entity is stored in the entity's cellData attribute. The cellData attribute is a 
dictionary that corresponds to the default value in the entity's .def file, 
as well as the "position", "direction", and "spaceID" used to represent 
the entity's position and orientation (roll, pitch, yaw).
</div>

<p>
<span class="function_parameter">parameters:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr valign=top><td><span class="function_parameter_name"><i>cellEntityCall</i></span></td><td><span class="function_parameter_description">
<a href=../../keywords.html#EntityCall>CellEntityCall</a> parameter 
that specifies which space to create this cell entity in.
<br><br>
Only a direct <a href=../../keywords.html#EntityCall>CellEntityCall</a> 
may be used. If you have an entity's <a href=../../keywords.html#EntityCall>BaseEntityCall</a>, 
you cannot pass its <i>baseEntityCall.cell</i> to this function. Instead, you must create 
a new function on the current entity's base that accepts a direct <a href=../../keywords.html#EntityCall>CellEntityCall</a> 
as a parameter and then calls this function using it.
<br><br>
E.g.
<pre>baseEntityCallOfNearbyEntity.createCellNearSelf( self )</pre>
On the nearby entity's base:
<pre>def createCellNearSelf( self, baseEntityCall ):
    baseEntityCall.createCellNearHere( self.cell )</pre>
On the current entity's base: 
<pre>def createCellNearHere( self, cellEntityCall ):
    self.createCellEntity( cellEntityCall )</pre>
</span></td></tr>

</table>
</p>

<a name="createCellEntityInNewSpace"></a><p class="function_definition">
<span class="function_definition">def createCellEntityInNewSpace( <i>self, cellappIndex</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
Create a space on the cellapp and create the <a href=../../keywords.html#cell>cell</a> 
of this entity into the new space. It requests to complete through cellappmgr.
<br><br>
The information used to create the cell entity is stored in the entity's cellData attribute. This property is a dictionary. The default values in the corresponding entity's .def file also include 
"position", "direction", and "spaceID" for representing the entity's position and orientation (roll, pitch, yaw).
</div>

<p>
<span class="function_parameter">parameters:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr valign=top><td><span class="function_parameter_name"><i>cellappIndex</i></span></td><td><span class="function_parameter_description">
integer, if it is either None or 0, a cellapp is dynamically selected by 
the engine load balancer. If it is greater than 0, a space is created in 
the specified cellapp<br>
Example: If you expect to open four cellapps, then the cellappIndex needs 
to specify the index can be <br>
1, 2, 3, 4,<br>
if the actual running cellapp is less than 4, for example, only 3, then 
the cellappIndex input 4 due to the number of overflow 4 1, 5 2.<br><br>

Tip: This feature can be used in conjunction with KBEngine.setAppFlags 
(KBEngine.APP_FLAGS_NOT_PARTCIPATING_LOAD_BALANCING), for example: 
placing large map spaces in several fixed cellapps and setting these 
cellapps to not participate in load balancing, and other cellapps to 
place copy space. When the copyspace is created and the cellappIndex is 
set to 0 or None, the consumption of the copy map will not affect the 
large map process, thus ensuring the smoothness of the main scene.
</span></td></tr>

</table>
</p>


<a name="delTimer"></a><p class="function_definition">
<span class="function_definition">def delTimer( <i>self, id</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
The function delTimer is used to remove a registered timer. The removed 
timer is no longer executed. Single-shot timers are 
automatically removed after the callback is executed, and it is not 
necessary to use the delTimer to remove it. If the delTimer function 
uses an invalid id (for example, has been removed), it will generate an 
error. 
<br><br>
A usage example is with the <a href="Entity.html">Entity</a>.<a href=Entity.html#addTimer>addTimer</a> 
function.
</div>

<p>
<span class="function_parameter">parameters:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr valign=top><td><span class="function_parameter_name"><i>id</i></span></td><td><span class="function_parameter_description">
integer, which specifies the timer id to remove. If the parameter is the string "All", all timers are removed at once.
</span></td></tr>

</table>
</p>

<a name="destroy"></a><p class="function_definition">
<span class="function_definition">def destroy( <i>self, deleteFromDB, writeToDB</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
This function destroys the base parts of the entity. If the entity has a 
cell part, then the user must first destroy the cell part, otherwise it 
will generate an error. To destroy the cell part of the entity, call a <a href="Entity.html">Entity</a>.<a href=Entity.html#destroyCellEntity>destroyCellEntity</a>.
<br><br>
It may be more appropriate to call self.destroy in the onLoseCell callback. 
This ensures that the base part of the entity is destroyed.
</div>

<p>
<span class="function_parameter">parameters:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr valign=top><td><span class="function_parameter_name"><i>deleteFromDB</i></span></td><td><span class="function_parameter_description">
If True, the entry associated with this entity in the database will be 
deleted. This parameter defaults to False.
</span></td></tr>

<tr valign=top><td><span class="function_parameter_name"><i>writeToDB</i></span></td><td><span class="function_parameter_description">
If True, the archived attributes associated with this entity will be 
written to the database. Only if this entity is read for the database or 
uses <a href="Entity.html">Entity</a>.<a href=Entity.html#writeToDB>writeToDB</a> 
will it be written to the database. This parameter is True by default, 
but will be ignore when deleteFromDB is True.
</span></td></tr>

</table>
</p>

<a name="destroyCellEntity"></a><p class="function_definition">
<span class="function_definition">def destroyCellEntity( <i>self</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
<i>destroyCellEntity</i> requests destruction of the associated cell 
entity. This method will generate an error if there is no associated 
cell entity.
</div>


<a name="writeToDB"></a><p class="function_definition">
<span class="function_definition">def writeToDB( <i>self, callback, shouldAutoLoad, dbInterfaceName</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
This function saves the entity's archive attributes to the database so 
that it can be loaded again when needed.
<br><br>
Entities can also be marked as automatically loaded so that the entity 
will be re-created when the service is started.
</div>

<p>
<span class="function_parameter">parameters:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr valign=top><td><span class="function_parameter_name"><i>callback</i></span></td><td><span class="function_parameter_description">
This optional parameter is a callback function when the database operation 
is complete. It has two parameters. The first is a success or failure 
boolean flag, and the second is the base entity.
</span></td></tr>

<tr valign=top><td><span class="function_parameter_name"><i>shouldAutoLoad</i></span></td><td><span class="function_parameter_description">
This optional parameter specifies whether this entity needs to be loaded 
from the database when the service is started. <br>
Note: The entity is automatically loaded when the server starts. The 
default is to call createEntityAnywhereFromDBID to create an entity to a 
minimally loaded baseapp. The entire process will be completed before the 
first started baseapp calls onBaseAppReady.
<br><br>

The script layer can reimplement the entity creation method in the 
personalization script (kbengine_defaults.xml->baseapp->entryScriptFile definition), 
for example: <br>
def onAutoLoadEntityCreate(entityType, dbid): 
      KBEngine.createEntityFromDBID(entityType, dbid)
</span></td></tr>

<tr valign=top><td><span class="function_parameter_name"><i>dbInterfaceName</i></span></td><td><span class="function_parameter_description">
string, optional parameter, specified by a database interface, default is to 
use the "default" interface. Database interfaces are defined in 
kbengine_defaults.xml->dbmgr->databaseInterfaces.
</span></td></tr>

</table>
</p>


<a name="getComponent"></a><p class="function_definition">
<span class="function_definition">def getComponent( <i>self, componentName, all</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
Gets a component instance of the specified type attached to the entity.
</div>

<p>
<span class="function_parameter">parameters:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr valign=top><td><span class="function_parameter_name"><i>componentName</i></span></td><td><span class="function_parameter_description">
string, The component type name.
</span></td></tr>

<tr valign=top><td><span class="function_parameter_name"><i>all</i></span></td><td><span class="function_parameter_description">
bool, if True, Returns all instances of the same type of component, otherwise only returns the first or empty list.
</span></td></tr>
</table>
</p>


<a name="fireEvent"></a><p class="function_definition">
<span class="function_definition">def fireEvent( <i>self, eventName, *args</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
Trigger entity events.
</div>

<p>
<span class="function_parameter">parameters:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr valign=top><td><span class="function_parameter_name"><i>eventName</i></span></td><td><span class="function_parameter_description">
string, the name of the event to trigger.
</span></td></tr>

<tr valign=top><td><span class="function_parameter_name"><i>args</i></span></td><td><span class="function_parameter_description">
The event datas to be attached, variable parameters.
</span></td></tr>
</table>
</p>


<a name="registerEvent"></a><p class="function_definition">
<span class="function_definition">def registerEvent( <i>self, eventName, callback</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
Register entity events.
</div>

<p>
<span class="function_parameter">parameters:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr valign=top><td><span class="function_parameter_name"><i>eventName</i></span></td><td><span class="function_parameter_description">
string, the name of the event to be registered for listening.
</span></td></tr>

<tr valign=top><td><span class="function_parameter_name"><i>callback</i></span></td><td><span class="function_parameter_description">
The callback method used to respond to the event when the event fires.
</span></td></tr>
</table>
</p>


<a name="deregisterEvent"></a><p class="function_definition">
<span class="function_definition">def deregisterEvent( <i>self, eventName, callback</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
Deregister entity events.
</div>

<p>
<span class="function_parameter">parameters:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr valign=top><td><span class="function_parameter_name"><i>eventName</i></span></td><td><span class="function_parameter_description">
string, the name of the event to be deregister.
</span></td></tr>

<tr valign=top><td><span class="function_parameter_name"><i>callback</i></span></td><td><span class="function_parameter_description">
The callback method to deregister of the listener.
</span></td></tr>
</table>
</p>


<hr>
<h2>Callback functions documentation</h2>

<a name="onCreateCellFailure"></a><p class="function_definition">
<span class="function_definition">def onCreateCellFailure( <i>self</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
If this function is implemented in the script, this function is called when the cell entity fails to create. This function has no parameters.
</div>

<a name="onDestroy"></a><p class="function_definition">
<span class="function_definition">def onDestroy( <i>self</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
If this callback function is implemented in a script, it is called after 
<a href="Entity.html">Entity</a>.<a href=Entity.html#destroy>destroy</a>() 
actually destroys the entity. This function has no parameters.
</div>

<a name="onGetCell"></a><p class="function_definition">
<span class="function_definition">def onGetCell( <i>self</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
If this function is implemented in the script, this function is called when it gets a cell entity. This function has no parameters.
</div>

<a name="onLoseCell"></a><p class="function_definition">
<span class="function_definition">def onLoseCell( <i>self</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
If this function is implemented in the script, this function is called after its associated cell entity is destroyed. This function has no parameters.
</div>

<a name="onPreArchive"></a><p class="function_definition">
<span class="function_definition">def onPreArchive( <i>self</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
If this function is implemented in a script, it is called before the 
entity is automatically written to the database. This callback is called 
before the <a href="Entity.html">Entity</a>.<a href=Entity.html#onWriteToDB>onWriteToDB</a> 
callback. If the callback returns False, the archive operation is aborted. 
This callback should return True to continue the operation. If this 
callback does not exist, the archiving operation continues.
</div>

<a name="onRestore"></a><p class="function_definition">
<span class="function_definition">def onRestore( <i>self</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
If this function is implemented in a script, it is called when this <a href="Entity.html">Entity</a>'s 
application crashes and the <a href="Entity.html">Entity</a> is recreated on 
other applications. This function has no parameters.
</div>

<a name="onTimer"></a><p class="function_definition">
<span class="function_definition">def onTimer( <i>self, timerHandle, userData</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
This function is called when a timer associated with this entity is 
triggered. A timer can be added using the <a href="Entity.html">Entity</a>.<a href=Entity.html#addTimer>addTimer</a> 
function.
</div>

<p>
<span class="function_parameter">parameters:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr valign=top><td><span class="function_parameter_name"><i>timerHandle</i></span></td><td><span class="function_parameter_description">
The id of the timer.
</span></td></tr>

<tr valign=top><td><span class="function_parameter_name"><i>userData</i></span></td><td><span class="function_parameter_description">
integer, User data passed in on <a href="Entity.html">Entity</a>.<a href=Entity.html#addTimer>addTimer</a>.
</span></td></tr>

</table>
</p>

<a name="onWriteToDB"></a><p class="function_definition">
<span class="function_definition">def onWriteToDB( <i>self, cellData</i> ):</span>
</p>

<div class="function_description">
<b>Function description:</b><br><br>
If this function is implemented in the script, this function is called when the entity data is to be written into the database.
<br><br>
Note that calling writeToDB in this callback will result in an infinite loop.
</div>

<p>
<span class="function_parameter">parameters:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">

<tr valign=top><td><span class="function_parameter_name"><i>cellData</i></span></td><td><span class="function_parameter_description">
Contains the cell properties that will be stored in the database. 
<a href="Entity.html#cellData">cellData</a> is a dictionary.
</span></td></tr>

</table>
</p>

<hr>
<h2>Attributes documentation</h2>

<a name="cell"></a><p class="attribute_definition">
<span class="attribute_definition">cell</span>
</p>

<div class="attribute_description">
<b>Description:</b><br><br>
cell is the <a href=../../keywords.html#EntityCall>ENTITYCALL</a> used to 
contact the cell entity. This property is read-only, and the property is 
set to None if this base entity has no associated cell.
<br><br>
</div>

<p>
<span class="attribute_type">Type:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">
<tr><td>Read-only <a href=../../keywords.html#EntityCall>ENTITYCALL</a>
</td></tr>
</table>
</p>

<a name="cellData"></a><p class="attribute_definition">
<span class="attribute_definition">cellData</span>
</p>

<div class="attribute_description">
<b>Description:</b><br><br>
cellData is a dictionary property. Whenever the base entity does not 
create its cell entity, the attributes of the cell entity are stored here. 
<br><br>
If the cell entity is created, these used values and <a href=#cellData>cellData</a> 
attributes will be deleted. In addition to the attributes that the cell 
entity specifies in the entity definition file, it also contains position, 
direction, and spaceID.
</div>

<p>
<span class="attribute_type">Type:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">
<tr><td><a href="CELLDATADICT.html">CELLDATADICT</a>
</td></tr>
</table>
</p>

<a name="className"></a><p class="attribute_definition">
<span class="attribute_definition">className</span>
</p>

<div class="attribute_description">
<b>Description:</b><br><br>
The class name of the entity.
</div>

<p>
<span class="attribute_type">Type:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">
<tr><td>Read-only string
</td></tr>
</table>
</p>

<a name="client"></a><p class="attribute_definition">
<span class="attribute_definition">client</span>
</p>

<div class="attribute_description">
<b>Description:</b><br><br>
client is the EntityCall used to contact the client. This attribute is 
read-only and is set to None if this base entity has no associated client.
</div>

<p>
<span class="attribute_type">Type:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">
<tr><td>Read-only <a href=../../keywords.html#EntityCall>ENTITYCALL</a>
</td></tr>
</table>
</p>

<a name="databaseID"></a><p class="attribute_definition">
<span class="attribute_definition">databaseID</span>
</p>

<div class="attribute_description">
<b>Description:</b><br><br>
databaseID is the entity's permanent ID (database id). This id is of type 
uint64 and is greater than 0. If it is 0 then the entity is not permanent.
</div>

<p>
<span class="attribute_type">Type:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">
<tr><td>Read-only int64
</td></tr>
</table>
</p>

<a name="databaseInterfaceName"></a><p class="attribute_definition">
<span class="attribute_definition">databaseInterfaceName</span>
</p>

<div class="attribute_description">
<b>Description:</b><br><br>
databaseInterfaceName is the database interface name where the entity 
persists. The interface name is configured in kbengine_defaults->dbmgr. 
The entity must be persistent (databaseID>0) for this attribute to be 
available, otherwise an empty string is returned.
</div>

<p>
<span class="attribute_type">Type:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">
<tr><td>Read-only string
</td></tr>
</table>
</p>


<a name="id"></a><p class="attribute_definition">
<span class="attribute_definition">id</span>
</p>

<div class="attribute_description">
<b>Description:</b><br><br>
id is the object id of the entity. This id is an integer that is the same between base, cell, and client associated entities. This attribute is read-only.
</div>

<p>
<span class="attribute_type">Type:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">
<tr><td>Read-only int32
</td></tr>
</table>
</p>

<a name="isDestroyed"></a><p class="attribute_definition">
<span class="attribute_definition">isDestroyed</span>
</p>

<div class="attribute_description">
<b>Description:</b><br><br>
This attribute is True if the <a href="Entity.html">Entity</a> has been 
destroyed.
</div>

<p>
<span class="attribute_type">Type:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">
<tr><td>bool
</td></tr>
</table>
</p>

<a name="shouldAutoArchive"></a><p class="attribute_definition">
<span class="attribute_definition">shouldAutoArchive</span>
</p>

<div class="attribute_description">
<b>Description:</b><br><br>
This attribute determines the automatic archiving strategy. If set to True, 
AutoArchive will be available, if set to False AutoArchive will not be available. 
If set to <a href="../Modules/KBEngine.html">KBEngine</a>.<a href=KBEngine.html#NEXT_ONLY>NEXT_ONLY</a>, 
automatic archiving will be available at the next scheduled time. This 
attribute will be set to false after the next archiving.
</div>

<p>
<span class="attribute_type">Type:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">
<tr><td>True, False or <a href="../Modules/KBEngine.html">KBEngine</a>.<a href=KBEngine.html#NEXT_ONLY>NEXT_ONLY</a>
</td></tr>
</table>
</p>

<a name="shouldAutoBackup"></a><p class="attribute_definition">
<span class="attribute_definition">shouldAutoBackup</span>
</p>

<div class="attribute_description">
<b>Description:</b><br><br>
This attribute determines the automatic bacup strategy. If set to True, 
automatic backup will be available, if set to False, automatic backup 
will not be available. If set to <a href="../Modules/KBEngine.html">KBEngine</a>.<a href=KBEngine.html#NEXT_ONLY>NEXT_ONLY</a>, 
automatic backup will be done at the next available predetermined time. 
After the next backup, this attribute will be set to False.
</div>

<p>
<span class="attribute_type">Type:</span>
<table border=0 cellpadding=0 cellspacing=3 style="margin-left: 20px;">
<tr><td>True, False or <a href="../Modules/KBEngine.html">KBEngine</a>.<a href=KBEngine.html#NEXT_ONLY>NEXT_ONLY</a>
</td></tr>
</table>
</p>


<hr>
<p class="copyrightFooter">Copyright KBEngine</p>
</body>
</html>
